#-------------------------------[知乎：叶枝黎曼]-------------------------
def nexP(index):
    #global s 
    for t in range(index):
        if n <= 1:
            return
        for i in range(n - 2,-1,-1):
            if s[i] < s[i + 1]:
                for j in range(n - 1,-1,-1):
                    if s[j] > s[i]:
                        s[i],s[j] = s[j],s[i]
                        s[i+1:] = sorted(s[i + 1:])
                        break
                break
            else:
                if i == 0:
                    s.sort()

n = int(input())
index=  int(input())
s = [int(i) for i in input().split()]

nexP(index)
print(' '.join(map(str,s)))
